const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');
const User = require('./User');

const SheetMusic = sequelize.define('SheetMusic', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  title: {
    type: DataTypes.STRING,
    allowNull: false
  },
  artist: {
    type: DataTypes.STRING,
    allowNull: false
  },
  content: {
    type: DataTypes.JSON,
    allowNull: false
  },
  isPublic: {
    type: DataTypes.BOOLEAN,
    defaultValue: false
  }
});

// 设置关联关系
SheetMusic.belongsTo(User, { foreignKey: 'userId' });
User.hasMany(SheetMusic, { foreignKey: 'userId' });

module.exports = SheetMusic; 